clear
rng default

workers=600;
n_types=5;

fp0='../r5/[6]'; %insert correct path


miss_M=cell(n_types,1);
miss_W=cell(n_types,1);

%MEN
for j=1:n_types

fp=['../r5/[6]/M/M_', int2str(j)]; 


IdSetM_temp=cell(workers,1);
miss_temp=[];
for ii = 1:workers
    filepath = fullfile( fp, ['IdSetM.' num2str(ii) '.mat'] );
    if exist( filepath, 'file' )
       A = getfield( load( filepath ), 'IdSetM' ); 
       IdSetM_temp{ii}=A;
    else
        miss_temp=[miss_temp ii];
    end
end
miss_M{j}=miss_temp;
IdSetM_final= vertcat(IdSetM_temp{:}); 

outpath = fullfile( fp0, ['IdSetM_final_' num2str(j) '.mat'] );
save( outpath, 'IdSetM_final' );
end



%WOMEN
for j=1:n_types

fp=['../r5/[6]/W/W_', int2str(j)]; 


IdSetM_temp=cell(workers,1);
miss_temp=[];
for ii = 1:workers
    filepath = fullfile( fp, ['IdSetM.' num2str(ii) '.mat'] );
    if exist( filepath, 'file' )
       A = getfield( load( filepath ), 'IdSetM' ); 
       IdSetM_temp{ii}=A;
    else
        miss_temp=[miss_temp ii];
    end
end
miss_W{j}=miss_temp;
IdSetW_final= vertcat(IdSetM_temp{:}); 

outpath = fullfile( fp0, ['IdSetW_final_' num2str(j) '.mat'] );
save( outpath, 'IdSetW_final' );
end

 

